<?php

namespace App\Http\Controllers;



use App\Models\SentenceSegmentRecord;
use App\Services\TranslateService;
use Illuminate\Http\Request;

use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Cache;


class IndexController extends Controller
{


    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $prent)
    {

        return view('translate.view');
    }

    public function transfer(Request $prent){
        $inputLanguage = $prent['inputLanguage'];
        $outputLanguage = $prent['outputLanguage'];
        $input = $prent['input'];
        $translateService = new TranslateService();
        $result = $translateService->getTranslate($inputLanguage,$outputLanguage,$input);
//        $sentenceSegmentRecord = SentenceSegmentRecord::query()->where('source_name',$input)->orWhere('target_name','$input')->first();
//        if($sentenceSegmentRecord){
//            if($sentenceSegmentRecord->source_language_code==$inputLanguage){
//                $sentenceSegmentRecord = SentenceSegmentRecord::query()->where('source_name',$input)->orWhere('target_name','$input')->first();
//            }else{
//
//            }
//        }
        return $this->success($result);
    }

}

